package com.changgou.business.listener;

import com.sun.javafx.collections.MappingChange;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.net.URI;
import java.util.Map;

@Component
public class ADListener {
    @Autowired
    RestTemplate restTemplate;
    //从rabbitmq中接收改变过得广告信息
    //http://192.168.200.128/ad_update?position=web_index_lb
    @RabbitListener(queues = "ad_update_quequ")
    public void receiveMessage(String position){
        System.out.println("接收到的 消息"+position);
        String url="http://192.168.200.128/ad_update?position="+position;
        ResponseEntity<Map> forEntity = restTemplate.getForEntity(url, Map.class);
        Map body = forEntity.getBody();
        System.out.println(body);
    }
}
